<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="沙盘显示屏">
    <title>沙盘显示屏 - 大屏端</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Arial', sans-serif;
            background: #000;
            height: 100vh;
            overflow: hidden;
            cursor: none;
        }

        .container {
            display: flex;
            flex-direction: column;
            height: 100vh;
            position: relative;
        }

        .header {
            background: rgba(0, 0, 0, 0.8);
            backdrop-filter: blur(10px);
            padding: 15px 30px;
            color: white;
            display: flex;
            justify-content: space-between;
            align-items: center;
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            z-index: 100;
            transition: opacity 0.3s;
        }

        .header.hidden {
            opacity: 0;
            pointer-events: none;
        }

        .title {
            font-size: 28px;
            font-weight: bold;
            color: #fff;
        }

        .status-info {
            display: flex;
            align-items: center;
            gap: 20px;
        }

        .status {
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .status-indicator {
            width: 16px;
            height: 16px;
            border-radius: 50%;
            background: #ff4444;
            transition: background 0.3s;
        }

        .status-indicator.connected {
            background: #44ff44;
        }

        .time-display {
            font-size: 18px;
            font-family: monospace;
        }

        .main-content {
            flex: 1;
            position: relative;
            background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
        }

        .sandbox-area {
            width: 100%;
            height: 100%;
            position: relative;
            overflow: hidden;
        }

        #sandbox-canvas {
            width: 100%;
            height: 100%;
            display: block;
            background: rgba(255, 255, 255, 0.95);
            cursor: none;
        }

        .canvas-overlay {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            pointer-events: none;
            z-index: 10;
        }

        .remote-cursor {
            position: absolute;
            width: 24px;
            height: 24px;
            background: radial-gradient(circle, rgba(255, 0, 0, 0.8) 0%, rgba(255, 0, 0, 0.3) 70%, transparent 100%);
            border-radius: 50%;
            pointer-events: none;
            transition: all 0.1s;
            transform: translate(-50%, -50%);
            z-index: 20;
        }

        .remote-cursor::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 8px;
            height: 8px;
            background: #ff0000;
            border-radius: 50%;
            transform: translate(-50%, -50%);
        }

        .info-panel {
            position: absolute;
            bottom: 20px;
            right: 20px;
            background: rgba(0, 0, 0, 0.7);
            backdrop-filter: blur(10px);
            color: white;
            padding: 15px 20px;
            border-radius: 15px;
            font-family: monospace;
            font-size: 14px;
            min-width: 200px;
            transition: opacity 0.3s;
        }

        .info-panel.hidden {
            opacity: 0;
        }

        .info-row {
            display: flex;
            justify-content: space-between;
            margin-bottom: 5px;
        }

        .info-row:last-child {
            margin-bottom: 0;
        }

        .connection-status {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            text-align: center;
            color: white;
            font-size: 24px;
            z-index: 50;
        }

        .connection-status.hidden {
            display: none;
        }

        .config-btn {
            background: rgba(255, 255, 255, 0.2);
            border: none;
            border-radius: 50%;
            width: 40px;
            height: 40px;
            font-size: 16px;
            cursor: pointer;
            transition: all 0.3s ease;
            color: white;
            margin-top: 20px;
        }

        .config-btn:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: scale(1.1);
        }

        .loading-spinner {
            width: 60px;
            height: 60px;
            border: 4px solid rgba(255, 255, 255, 0.3);
            border-top: 4px solid #fff;
            border-radius: 50%;
            animation: spin 1s linear infinite;
            margin: 20px auto;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .fullscreen-controls {
            position: absolute;
            top: 20px;
            right: 20px;
            z-index: 200;
        }

        .control-btn {
            background: rgba(0, 0, 0, 0.6);
            border: none;
            color: white;
            padding: 10px 15px;
            border-radius: 8px;
            cursor: pointer;
            font-size: 16px;
            margin-left: 10px;
            transition: all 0.3s;
        }

        .control-btn:hover {
            background: rgba(0, 0, 0, 0.8);
            transform: scale(1.05);
        }

        .drawing-indicator {
            position: absolute;
            top: 20px;
            left: 20px;
            background: rgba(76, 175, 80, 0.9);
            color: white;
            padding: 10px 20px;
            border-radius: 25px;
            font-size: 16px;
            font-weight: bold;
            z-index: 100;
            opacity: 0;
            transition: opacity 0.3s;
        }

        .drawing-indicator.active {
            opacity: 1;
        }

        .qr-code {
            position: absolute;
            bottom: 20px;
            left: 20px;
            background: white;
            padding: 15px;
            border-radius: 10px;
            text-align: center;
            font-size: 12px;
            color: #333;
            max-width: 150px;
            transition: opacity 0.3s;
        }

        .qr-code.hidden {
            opacity: 0;
        }

        /* 响应式设计 */
        @media (max-width: 1024px) {
            .header {
                padding: 10px 20px;
            }
            
            .title {
                font-size: 24px;
            }
            
            .info-panel {
                bottom: 10px;
                right: 10px;
                font-size: 12px;
            }
        }

        @media (max-width: 768px) {
            .header {
                padding: 8px 15px;
            }
            
            .title {
                font-size: 20px;
            }
            
            .status-info {
                gap: 10px;
            }
            
            .time-display {
                font-size: 14px;
            }
        }

        /* 自动隐藏界面元素 */
        .auto-hide {
            transition: opacity 0.5s;
        }

        .auto-hide.fade-out {
            opacity: 0;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header auto-hide" id="header">
            <div class="title">📺 沙盘显示屏</div>
            <div class="status-info">
                <div class="status">
                    <span>连接:</span>
                    <div class="status-indicator" id="status-indicator"></div>
                    <span id="status-text">未连接</span>
                </div>
                <div class="time-display" id="time-display"></div>
            </div>
        </div>

        <div class="fullscreen-controls">
            <button class="control-btn" id="fullscreen-btn" title="全屏模式">⛶</button>
            <button class="control-btn" id="settings-btn" title="设置">⚙️</button>
        </div>

        <div class="drawing-indicator" id="drawing-indicator">
            🎨 正在绘制...
        </div>

        <div class="main-content">
            <div class="sandbox-area">
                <canvas id="sandbox-canvas"></canvas>
                <div class="canvas-overlay">
                    <div class="remote-cursor" id="remote-cursor" style="display: none;"></div>
                </div>
            </div>
        </div>

        <div class="connection-status" id="connection-status">
            <div class="loading-spinner"></div>
            <div>等待连接控制端...</div>
            <div style="font-size: 16px; margin-top: 10px; color: rgba(255, 255, 255, 0.7);">
                请在手机上打开控制界面
            </div>
            <button class="config-btn" onclick="openIPConfig()" title="配置服务器IP">⚙️</button>
        </div>

        <div class="info-panel auto-hide" id="info-panel">
            <div class="info-row">
                <span>分辨率:</span>
                <span id="resolution">-</span>
            </div>
            <div class="info-row">
                <span>FPS:</span>
                <span id="fps">-</span>
            </div>
            <div class="info-row">
                <span>延迟:</span>
                <span id="latency">-</span>
            </div>
            <div class="info-row">
                <span>控制端:</span>
                <span id="controller-count">0</span>
            </div>
        </div>

        <div class="qr-code auto-hide" id="qr-code">
            <div style="width: 100px; height: 100px; background: #f0f0f0; margin-bottom: 10px; display: flex; align-items: center; justify-content: center; font-size: 12px; color: #666;">
                📱 QR码
            </div>
            <div>扫码连接控制端</div>
        </div>
    </div>

    <script src="js/qrcode.min.js"></script>
    <script src="js/sandbox.js"></script>
    <script src="js/websocket.js"></script>
    <script src="js/display-screen.js"></script>
    <script>
        function openIPConfig() {
            window.location.href = 'ip-config.html';
        }
    </script>
</body>
</html>